<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="js/jquery-1.9.0.min.js"></script>
<link rel="stylesheet" href="js/pc/weChat/JqueryWeUi/weui.css" />
<link rel="stylesheet" href="js/pc/weChat/JqueryWeUi/example.css" />
<script src="https://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script src="http://res2.wx.qq.com/open/js/jweixin-1.4.0.js"></script>
</head>
<body>
	<script type="text/javascript">
		/* 
		 *个人信息接口 */
		 $(function(){
		 window.location.href="WeChat/accessToken/MultiCompanyRegistration.do";
		 })  
		/* $(function(){
		 window.location.href="pc/pay/Alipay/goPay.do";
		 })  */
	</script>
	<script type="text/javascript">
		$(function() {
			//alert(location.href);
			var obje = {
				url : location.href.split('#')[0]
			};
			$.ajax({
				type : "post",
				url : "WeChat/accessToken/testasdsadasdsadas.do",
				data : obje,
				dataType : "json",
				success : function(data) {
					wx.config({
						debug : false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。  
						appId : "wx7d7032171ddabf95", // 必填，公众号的唯一标识  
						timestamp : data.timestamp, // 必填，生成签名的时间戳  
						nonceStr : data.nonceStr, // 必填，生成签名的随机串  
						signature : data.signature,// 必填，签名，见附录1  
						jsApiList : [ 'checkJsApi', 'onMenuShareTimeline',
								'onMenuShareAppMessage', 'onMenuShareQQ',
								'onMenuShareWeibo', 'onMenuShareQZone',
								'hideMenuItems', 'showMenuItems',
								'hideAllNonBaseMenuItem',
								'showAllNonBaseMenuItem', 'translateVoice',
								'startRecord', 'stopRecord',
								'onVoiceRecordEnd', 'playVoice',
								'onVoicePlayEnd', 'pauseVoice', 'stopVoice',
								'uploadVoice', 'downloadVoice', 'chooseImage',
								'previewImage', 'uploadImage', 'downloadImage',
								'getNetworkType', 'openLocation',
								'getLocation', 'hideOptionMenu',
								'showOptionMenu', 'closeWindow', 'scanQRCode',
								'chooseWXPay', 'openProductSpecificView',
								'addCard', 'chooseCard', 'openCard' ]
					});

				},
				error : function() {
				}
			});
		});
	</script>
 <img  src="http://thirdwx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTLiaibP1efgjsJjzDeGgZWYpELicFLCH0n46fHPakc6U1IgXwWbpKaiasDDuibPaSs3ecK8AeOiahBg9QfQ/132">
	<script type="text/javascript">
		function onBridgeReady() {
			$.post("WeChat/accessToken/Order.do", function(data) {
				console.log(data);
				var appId = data.appId;
				var timeStamp = data.timeStamp;
				var nonceStr = data.nonceStr;
				var wxPackage = data.wpackage;
				var signType = data.signType;
				var paySign = data.paySign;
				pay(appId, timeStamp, nonceStr, wxPackage, signType, paySign);
			}, "json")

		}

		function pay(appId, timeStamp, nonceStr, wxPackage, signType, paySign) {
			WeixinJSBridge.invoke('getBrandWCPayRequest', {
				"appId" : appId, //公众号名称，由商户传入       
				"timeStamp" : timeStamp, //时间戳，自1970年以来的秒数       
				"nonceStr" : nonceStr, //随机串       
				"package" : wxPackage,
				"signType" : signType, //微信签名方式:       
				"paySign" : paySign
			//微信签名   
			}, function(res) {
				if (res.err_msg == "get_brand_wcpay_request:ok") {
					$.post("WeChat/accessToken/orderqueryPay.do?",function(data){
						if(data.type==1){
							alert(data.msg);
						}else{
							alert(data.msg);
						}
					},"json")
				} else if (res.err_msg == "get_brand_wcpay_request:cancel") {
					alert("不要取消支付啊，我们就差一步就能见面");
					window.location.href="";
				} else if (res.err_msg == "get_brand_wcpay_request:fail") {
					alert("支付失败");//
					window.location.href="";
				}
				// 使用以上方式判断前端返回,微信团队郑重提示：res.err_msg将在用户支付成功后返回    ok，但并不保证它绝对可靠。   
			});
		}
		function orderquery(){
			$.post("WeChat/accessToken/orderquery.do",function(data){
				if(data.type==1){
					alert(data.msg);
				}else{
					alert(data.msg);	
				}
					
			},"json")
		}
		function refund(){
	$.post("tuikuan.do",function(data){
				
			},"json")
		}
	</script>
	openid
	<input value="oqqrN54lkwFz7nHEcA56Ja0lpK2w">
	<div>
		<input style="margin-left: 90px; height: 90px; width: 90px;"
			type="button" onclick="onBridgeReady()" value="立即支付">
			<input style="margin-left: 90px; height: 90px; width: 90px;" type="button" onclick="orderquery()" value="查询订单">
				<input style="margin-left: 90px; height: 90px; width: 90px;"
			type="button" onclick="refund()" value="退款">
	</div>
</body>
</html>